package com.oocl.homework.crm.model;

public class UserFilter implements Filterable {
	
	
	@Override
	public Result filter(String[] attributes) {
		Result result = new Result();
		result.setCode(1);
		for(int i=0;i<attributes.length;i++){
			if(!isAttribute(attributes[i])){
				result.setCode(-1);
				result.setMessage("User has no attribute name:"+attributes[i]);
			}
		}
		return result;
	}
	
	private boolean isAttribute(String attribute){
		return attribute.equals("id")||attribute.equals("name")||attribute.equals("sex")||attribute.equals("birthday")||attribute.endsWith("address")||attribute.equals("phone");
	}
	
	
	
	
}
